<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="apple-touch-fullscreen" content="yes" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<!-- 删除苹果默认的工具栏和菜单栏 -->
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
		<!-- 设置苹果工具栏颜色 -->
		<meta name="format-detection" content="telphone=no, email=no" />
		<!-- 忽略页面中的数字识别为电话，忽略email识别 -->
		<meta name="renderer" content="webkit" />
		<!-- 启用360浏览器的极速模式(webkit) -->
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<!-- 避免IE使用兼容模式 -->
		<meta name="HandheldFriendly" content="true" />
		<!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
		<meta name="MobileOptimized" content="480" />
		<!-- 微软的老式浏览器 -->
		<meta name="screen-orientation" content="portrait" />
		<!-- uc强制竖屏 -->
		<meta name="x5-orientation" content="portrait" />
		<!-- QQ强制竖屏 -->
		<meta name="format-detection" content="telephone=no" />
		<!-- 去除苹果浏览器自带link -->
		<title>{$novel_name}</title>
		<script src="__PUBLIC__/page/js/prefixfree.min.js"></script>
		<link href="__PUBLIC__/page/css/beos.css" rel="stylesheet" />
		<link href="__PUBLIC__/page/css/swiper-3.4.2.min.css" rel="stylesheet" />
		<link href="__PUBLIC__/page/css/Style.css" rel="stylesheet" />
		<link href="__PUBLIC__/page/css/front.css" rel="stylesheet">
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/page/layer/need/layer.css"/>
</head>
	<body>
		<section class="section">
			<h3>加载中...</h3>
		</section>
		<input type="hidden" id="domain" value="{$domain}" />		
		<div class="MaxBody">	
			
			<!--隐藏菜单-->
				<div class="Huanxing">
					<div class="Top">
						<ul>						
							<li>
								<a onclick="backs()" title="返回上一页"><img src="__PUBLIC__/page/img/icon-fh.png" alt="返回上一页" /></a>
							</li>
							<li>第二章</li>
							<li>
								<a href="/Home/Novel/getClassList" title="我的书库"><img src="__PUBLIC__/page/img/icon-sj.png" alt="我的书库" /></a>
							</li>
							<li>
								<a href="/Home/User/recharge" title="充值"><img src="__PUBLIC__/page/img/icon-rmb.png" alt="充值" /></a>
							</li>
						</ul>
					</div>					 
					<input type="hidden" id="novel_id" value="{$novel_id}" />
					<div class="Bottom">
						<ul>
							<li>
								<a class="muluButton">
									<img src="__PUBLIC__/page/img/icon-cd.png" alt="目录" />
									<p>目录</p>
								</a>
							</li>
							<li>
								<a class="Yejian">
									<img src="__PUBLIC__/page/img/icon-yl.png" alt="夜间模式" />
									<p>夜间</p>
								</a>
							</li>
							<li>
								<a class="Shuqian">
									<img src="__PUBLIC__/page/img/icon-sq.png" alt="书签" />
									<p>书签</p>
								</a>
							</li>
							<li>
								<a href="/Home/Index/index">
									<img src="__PUBLIC__/page/img/home100.png" alt="返回首页" />
									<p>首页</p>
								</a>
							</li>
						</ul>
					</div>
				</div>
				<!--隐藏菜单-->

			<!--目录-->
			<div class="Muli">
				<div id="fdleft">
					<div class="fdleftimg"><img src="__PUBLIC__/page/img/icon-fh.png" width="100%"/></div>
				</div>
				<ul style="float: left;">
					
				</ul>				
			</div>
			<!--目录-->

			<!-- Swiper -->
			<div class="swiper-container">
				<div class="centerbox"></div>
				<div class="swiper-wrapper "></div>
				<div class="swiper-pagination"></div>
				<div class="swiper-button-next swiper-button-white"></div>
       			<div class="swiper-button-prev swiper-button-white"></div>
			</div>
		</div>
		<input type="hidden" id="novel_title" value="{$novel_name}" />
		<input type="hidden" id="chapter_id" value="{$init_chapter_id}" />
		<input type="hidden" id="novel_img" value="{$novel_img}"/>
		<div class="recharge">
			<div class="box">
				<div class="reico"><img src="__PUBLIC__/page/img/gthico.png" width="100%"/></div>
				<div class="text">
					<p>您的可用余额已不足</p>
					<p class="textsmall">请充值！</p>
				</div>
				<div class="czico"><a href="/Home/User/recharge">充值</a></div>
			</div>
		</div>
		<input type="hidden" id="sign" value="{$sign}"/>
		<input type="hidden" id="tongjiurl" value="{$tongji}"/>
		<iframe id="myFrame" src="/Home/Novel/tongji.html?tongji={$tongji}" style="display: none;"></iframe>
		<div class="gz">
			<div class="box">
				<div class="text">
					<p>关注作者授权公众号继续阅读</p>
					<p class="textsmall">由于版权问题，请关注后继续阅读</p>
				</div>
				<div class="reico"><img src="__PUBLIC__/home/other/logo.jpg" width="100%"/></div>
				<div class="text">
					<p>长按上图识别二维码关注</p>
					<p class="textsmall">或搜索xs7971关注"最全小说"</p>
				</div>
			</div>
		</div>
		<div class="jzhd"></div>
		<div class="loginright ltop">
			<div class="loginrights"><img src="__PUBLIC__/page/img/loading-2.gif"/></div>
		</div>
		<div class="loginright lbottom">
			<div class="loginrights"><img src="__PUBLIC__/page/img/loading-2.gif"/></div>
		</div>
		<div class="signbox">
			<div class="signboxcontent">
				<h3>签到成功</h3>
				<p>每日首次阅读，赠送<span>20</span>书币</p>
				<p>请明日继续签到哦</p>
				<div class="contentbtn">我知道啦</div>
			</div>
		</div>	
		<div class='workbigbox'>
			<a href="">
				<div class='workgybox'>
					<div class='worktitle'>
						<div class='userimg'>
							<img src=''/>
						</div>
						<div class='username'></div>
						<div class='workright'></div>
					</div>
					<div class='workcontent'></div>
				</div>
			</a>
		</div>
	</body>
</html>
<script src="__PUBLIC__/page/js/jquery.min.js"></script>
<script src="__PUBLIC__/page/js/swiper.min.js"></script>
<script src="__PUBLIC__/page/layer/layer.js"></script>
<script>
	var sign=$('#sign').val();	
	var OneOpen = true; //第一次进页面
	var GlobalPageNumber = 0; //整体文章页数
	var ArticleNumber = 4; //当前文章章数
	var NewPageNumber = 0; //当前文章当前页数
	var NewSwiperPageNumber = 1; //控件当前位置
	var Zomgyesu = 1; //文章总章数(这里绑定文章总数-1)
	var Article = [];
	var idnumnext;
	var idnumbegin;
	var order_set;
	var result;
	var follow;
	var ids=$("#novel_id").val();
	var domain=$("#domain").val();
	var init_chapter_id=$("#chapter_id").val();
	var novel_img = $("#novel_img").val();
	var page = $("#page").val();
	var rootbox=true;
	var jd=true;
	var indexicos=1;
	var beginpd=true;
	var fanyetiom;
	var isMobile = {
        iOS: function () {
            return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
        }
    };
	var beginmove=1;
	var times;
	var tongjiurl=$("#tongjiurl").val();
	var workimg;
	var workname;
	var workcontent;
	var workurl;
	if(sign=='1'){
		$('.signbox').show();
	}else{
		$('.signbox').hide();
	}
	$('.contentbtn').click(function(){
		$('.signbox').hide();
	})
	function backs(){
		location.href=document.referrer;
	}
	function ajaxs(event){
		alert( event );
		$.ajax({
			url: event,
			type: 'get',
			dataType: 'json',
			async:true,
			success: function(data) {				
				if(data.is_identity==1){
					window.location.href=""+data.identity_url+"?redirect="+data.redirect_url+"";
					return false;
				}
				workimg=data.workimg;
				workname=data.workname;
				workcontent=data.workcontent;
				workurl=data.workurl;
				order_set=data.order_set-1;
				idnumnext=data.next_chapter_id;
				idnumbegin=data.pre_chapter_id;
				init_chapter_id=data.chapter_id;
				result=data.result;
				follow=data.is_show;				
				if(beginmove==0){
					result=1;
				}
				if(result==1){					
					if(rootbox==true){
						if(localStorage.getItem('historydata')!=undefined){
							var localboxget=localStorage.getItem('historydata');
							localboxgets=JSON.parse(localboxget);	
							for(var i in localboxgets){
								if(localboxgets[i][0]==ids){	
									if(localboxgets[i][1]==init_chapter_id){																			
										indexicos=localboxgets[i][2];
										rootbox=false;
									}
								}
							}				
						}
					}					
					var title=data.title;
					var deta=data.content;
					$(".Top li:eq(1)").text(title);
					$(".section").html("<h3>"+title+"</h3>"+deta);
					swiper.removeAllSlides(); //移除全部
					htmlwen();
					swiper.updateSlidesSize(); //更新	
					if(beginmove==0){
						swiper.slideTo(Article[ArticleNumber].length, 40, false);
						beginmove=1;
					}else{
						swiper.slideTo(indexicos, 40, false);	
					}					
					$(".Muli").hide();
				}else{
					$(".recharge").show();
					return;
				}
			},
			beforeSend:function(){
				$(".swiper-button-next,.swiper-button-prev").hide();
				layer.open({
				    type: 2
				    ,content: '加载中'
				});
			},
			complete:function(){
				history.pushState(null,null,"http://"+domain+"/Home/Novel/show/id/"+init_chapter_id+"/novel_id/"+ids);
				if(jd==true){
					numplus=order_set;
					munnew=order_set;
					sumbox=order_set;
					jd=false;					
				}
				if(munnew!=0){
					if(order_set<15&&beginpd==true){
						order_set=order_set;
					}else{
						order_set=order_set-(sumbox-numbers);
					}
				}else{
					order_set=order_set;
				}				
				beginpd=false;
				if(OneOpen){
					getchapterlist();
					OneOpen=false;
				}	
				$(".swiper-button-next,.swiper-button-prev").show();
				if(swiper.activeIndex==$(".Modsok").length){
					$('.workbigbox').show();
				}else{
					$('.workbigbox').hide();
				}
				layer.closeAll();
				locals();				
			}
		});
	}
	function locals(){		
		var historybox=[];
		var historys=[];
		if(localStorage.getItem('historydata')!=undefined){	
			var localboxget=localStorage.getItem('historydata');
			localboxgets=JSON.parse(localboxget);
			var localpd=true;				
			for(var i in localboxgets){
				if(localboxgets[i][0]==ids){
					historys[0]=ids;
					historys[1]=init_chapter_id;					
					historys[2]=swiper.activeIndex;					
					if(historys[2]<=0&&idnumbegin==null){
						historys[2]=1;
					}
					localboxgets[i]=historys;
					var localboxset=JSON.stringify(localboxgets);
					localStorage.setItem('historydata',localboxset);				
					localpd=false;
				}
			}
			if(localpd==true){				
				historys[0]=ids;
				historys[1]=init_chapter_id;
				historys[2]=swiper.activeIndex;
				localboxgets.push(historys);
				var localboxset=JSON.stringify(localboxgets);	
				localStorage.setItem('historydata',localboxset);				
			}				
		}else{
			historys[0]=ids;
			historys[1]=init_chapter_id;
			historys[2]=swiper.activeIndex;
			historybox[0]=historys;			
			var localboxset=JSON.stringify(historybox);
			localStorage.setItem('historydata',localboxset);
		}
	}	
	ajaxs("http://"+domain+"/Home/Novel/ajaxgetchapter?novel_id="+ids+"&chapter_id="+init_chapter_id);
	var pageX;
	var swiper = new Swiper('.swiper-container', {
		nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev',
		pagination: '.swiper-pagination',
        paginationType: 'progress',
		initialSlide: 1,
		speed: 300,
		slidesPerView: 1,
		paginationClickable: true,
		onSlideChangeStart:function(swiper){			
			$('.workbigbox').hide();
			$(".swiper-button-next,.swiper-button-prev").hide();
			if(swiper.activeIndex <= 0||swiper.activeIndex >= $(".swiper-slide").length - 1) {
				$(".jzhd").show();
				times=setTimeout(function(){
					$(".jzhd").hide();
				},1500)
			};
			fanyetiom=setTimeout(function(){
				$(".swiper-button-next,.swiper-button-prev").show();
			},500);
		},
		onTouchStart:function(swiper){
			pageX=swiper.touches.currentX;
		},
		onTouchMove:function(swiper){			
			var pageXs=swiper.touches.currentX-pageX;
			$('.workbigbox').css('transform',"translateX("+pageXs+"px)");
		},	
		onTouchEnd:function(){
			$('.workbigbox').css('transform',"translateX(0px)");
		},
		onSlideChangeEnd: function(swiper) { //页面翻完了回调			
			if(swiper.activeIndex==$(".Modsok").length){
				$('.workbigbox').show();
			}else{
				$('.workbigbox').hide();
			}
			document.getElementById("myFrame").src = "/Home/Novel/tongji.html?tongji="+tongjiurl+"";
			clearTimeout(fanyetiom);
			locals();			
			$(".swiper-button-next,.swiper-button-prev").show();
			clearTimeout(times)
			$(".jzhd").hide();
			var events=follow;
			var numlenth=Math.round($(".Modsok").length/2)
			if(events==1&&swiper.activeIndex>=numlenth){
				$(".gz").show();
				$(document).on("touchmove",function(){
					return false;
				})
			}								
			if(swiper.activeIndex <= 0) {
				if(idnumbegin==null) {
					layer.open({
					    content: '已经是第一章了!'
					    ,style: 'border:none;background-color:#000;color:#fff;width:80%;font-size:1.2em'
					    ,time: .8
					});
					swiper.slideTo(1, 0, false);
				} else {
					ArticleNumber--;
					//你假装这个定时函数是你的post，deta是请求来的数据	
					beginmove=0;
					ajaxs("http://"+domain+"/Home/Novel/ajaxgetchapter?novel_id="+ids+"&chapter_id="+idnumbegin)																	
				}
			} else if(swiper.activeIndex >= $(".swiper-slide").length - 1) {
				if(idnumnext==null) {
                    swiper.slideTo(Article[ArticleNumber].length, 40, false);
					locals();
                    layer.open({
                        type: 2
                        ,content: '加载中'
                    });
					window.location.href="/Home/Novel/novel_end/novel_id/"+ids+"";
//					layer.open({
//					    content: '已经是最后一章了!'
//					    ,style: 'border:none;background-color:#000;color:#fff;width:80%;font-size:1.2em'
//					    ,time: .8
//					});
//					swiper.slideTo(swiper.activeIndex - 1, 40, false);
				} else {
					ArticleNumber++;
					//你假装这个定时函数是你的post，deta是请求来的数据	
					indexicos=1;
					ajaxs("http://"+domain+"/Home/Novel/ajaxgetchapter?novel_id="+ids+"&chapter_id="+idnumnext)					
				}
			}
		}
	});

	//唤醒菜单
	$(".centerbox").click(function() {	
		$(".Huanxing").addClass("hxsd");
	});		
	$(".Huanxing").click(function() {			
		$(this).removeClass("hxsd");
	});

	//初始化文章
	function htmlwen() {
		$(".section").find("p").each(function(){
			if($(this).text().length==0){
				$(this).remove();
			}
			$(this).text($(this).text().replace(/\./g,"。"));
			$(this).text($(this).text().replace(/\?/g,"？"));
			$(this).text($(this).text().toUpperCase());
			var stringsarr=["\\s","\\/","\\[","\\]","\\+","\\*","\\^","\\$","\\(","\\)","\\\\","\\|","<",">"];
			var punctuations_news=$(this).text();
			var punctuations_pros;
			stringsarr.forEach(function(e){
				punctuations_pros=punctuations_news.replace(eval("/("+e+")/g"),"");
				punctuations_news=punctuations_pros;
			})			
			$(this).text(punctuations_news);
		})
		if(novel_img!=""){
			$(".section").find("h3").after("<p class='titleimg'><span class='titleimgleft'><img src='"+novel_img+"'/></span><span class='titleimgright'>"+$("#novel_title").val()+"</span></p>")
		}		
		htmlwens()
	}
	function htmlwens(){
		var OpenIndex = 0;
		var html = $(".section");		
		var title = html.find("h3"); //获取标题
		var ZhanshiHd;
		if(novel_img!=""){
			ZhanshiHd = title.height()+20;
//			$("#novel_img").remove();
//			novel_img="";
		}else{
			ZhanshiHd = title.height();
		}
		title.remove();
		var swiperWrapper = $("div.swiper-wrapper");
		Article[ArticleNumber] = [];
		var panduans=1;
		var arrnext=[];		
		var boxheight=html.height();		
		function aao(){
			if(Article[ArticleNumber][OpenIndex] == undefined)  {
				Article[ArticleNumber][OpenIndex] = "";
			}
		}
		if(isMobile.iOS()){
			$("body").addClass("iosfront");
		}
		aao();
		//添加标题
		Article[ArticleNumber][OpenIndex] += title.prop("outerHTML");
		//组合页面信息				
		html.append('<p id="mycl"><span>我</span></p>');
		var spanw=html.find("#mycl").find("span").width();
		var spanh=html.find("#mycl").find("span").height();
		var line_height=html.find("#mycl").height();
		var heights=$("#mycl").height();
		var fonts;		
		fontxh()
		function fontxh(){
			if(heights==$("#mycl").height()){
				$("#mycl").find("span").append("我")	
				fontxh();
			}else{
				fonts=$("#mycl").find("span").text().length+1;
				return;
			}			
		}
		html.find("#mycl").remove();		
		var fontbox=Math.floor(boxheight/line_height);
		html.find("p").each(function() {				
			var ThisOpen = $(this);
			var row_height =line_height;
			var row_all_height=row_height;
			var arrs=[];
			var arrpro=[];
			var font_count;
			var row;
			xunhuans();
			function xunhuans(){
				if(ThisOpen.height()<boxheight-ZhanshiHd) {
					ZhanshiHd+=ThisOpen.height();						
				} else {
					function rowsfc(event){
						row=1;
						while(1){
							if((event)-row_all_height>=row_height){
								row_all_height+=row_height;
								row++;
							}
							else{
								break;
							}
						}
					}
					function fontfz(event){
						font_count = 0;
						for(var i=1;i<=row;i++){
							if(i==1){
								font_count=fonts-2;							
							}
							else{
								font_count+=fonts;
							}
						}						
					}					
					function strzh(event){
						arrs=event.text();
						arrpro=arrs.substring(0,font_count);
						arrnext=arrs.substring(font_count);
						event.text(arrpro);
						var punctuations_pro;
						var punctuations_new=event.text();	
						var arrlength=arrpro.match(/[^\u4e00-\u9fa5]/g);
						if(arrlength!=null){
							for(var i=-1;i<arrlength.length;i++){
								for(var j=0;j<i;j++){
									if(arrlength[i]==arrlength[j]){
										arrlength.splice(i,1);
										i=-1;
										j=0;
									}
								}				
							}	
							arrlength.forEach(function(e){
								punctuations_pro=punctuations_new.replace(eval("/("+e+")/g"),"<span>"+e+"</span>");
								punctuations_new=punctuations_pro;
							})
						}											
						event.html(punctuations_new);							
						event.find("span").css({'width':spanw,'height':spanh});
						event.find("span").addClass("textspan");
					}					
					if(boxheight-ZhanshiHd>=row_height){						
						rowsfc(boxheight-ZhanshiHd);
						fontfz(row);					
						strzh(ThisOpen);
						ZhanshiHd+=ThisOpen.height();						
						if(arrnext.length!=0){
							panduans=0;						
						}
					}else{
						chaochus();
						function chaochus(){
							if(panduans==0){
								OpenIndex++;
								ThisOpen.before("<p>"+arrnext+"</p>");
								aao();
								ThisOpen.prev().css("text-indent","0em");	
								ZhanshiHd=ThisOpen.prev().height();
								if(boxheight-ZhanshiHd<0){
									rowsfc(boxheight);
									fontfz(row);
									font_count+=2;
									strzh(ThisOpen.prev());
									aao();
									Article[ArticleNumber][OpenIndex] += ThisOpen.prev().prop("outerHTML");	
									ThisOpen.prev().remove();
									row_all_height=row_height;
									chaochus();
								}else{
									Article[ArticleNumber][OpenIndex] += ThisOpen.prev().prop("outerHTML");	
									ThisOpen.prev().remove();
									panduans=1;
									arrnext=[];
									row_all_height=row_height;
									xunhuans();
								}							
							}else{
								OpenIndex++;
								ZhanshiHd=ThisOpen.height();
								if(boxheight-ZhanshiHd<0){
									rowsfc(boxheight);
									fontfz(row);
									strzh(ThisOpen);
									panduans=0;
								}
							}
						}
					}					
				}
			}
			aao();				
			//添加每一段落内容
			Article[ArticleNumber][OpenIndex] += ThisOpen.prop("outerHTML");
			$(this).remove();
		});	
		overpd();
		function overpd(){
			if(arrnext.length!=0){
				var allfont=fontbox*fonts;				
				OpenIndex++;
				aao();
				html.append("<p>"+arrnext+"</p>");
				html.find("p").css("text-indent","0em");
				ZhanshiHd=html.find("p").height();
				if(boxheight-ZhanshiHd<0){
					arrpro=arrnext.substring(0,allfont);
					html.find("p").text(arrpro);
					arrnext=arrnext.substring(allfont);
					Article[ArticleNumber][OpenIndex] += html.find("p").prop("outerHTML");	
					html.find("p").remove();
					overpd();
				}else{
					Article[ArticleNumber][OpenIndex] += html.find("p").prop("outerHTML");	
					html.find("p").remove();
					arrnext=null;
				}						
			}
		}		
		//显示页面信息
		for(var i = 0; i < Article[ArticleNumber].length + 2; i++) {
			if(i == 0) {
				swiperWrapper.append('<div class="swiper-slide" ></div>');
			} else if(i == Article[ArticleNumber].length + 1) {
				swiperWrapper.append('<div class="swiper-slide" ></div>');
			} else {
				swiperWrapper.append('<div class="swiper-slide" ><div class="Modsok">' + Article[ArticleNumber][i - 1] + '</div></div>');	
			}
		}
		$(".Modsok").each(function(){
			$(this).find("p:last").append('<span style="visibility:hidden;width:30px;display:inline-block">我</span>')
		})
		$('.userimg img').attr('src',workimg);
		$('.username').text(workname);
		$('.workcontent').text(workcontent);
		$('.workbigbox').find('a').attr('href',workurl);
		if($('body').height()-($('.swiper-slide').last().prev().find('p').last().offset().top+$('.swiper-slide').last().prev().find('p').last().height())>170){
			var workheight=$('.swiper-slide').last().prev().find('p').last().offset().top+$('.swiper-slide').last().prev().find('p').last().height()+20;
			$('.workbigbox').css('top',workheight);
		}else{
			var workheight=$('.Modsok').css('padding-top');
			$('.workbigbox').css('top',workheight);
			$('.swiper-slide').last().append('<div class="Modsok"></div>');
			$("div.swiper-wrapper").append('<div class="swiper-slide" ></div>');
		}
	}		
	//目录
	var numids;
	var panduan=true;
	var Fc = true; //防止重复点击	
	var numplus;
	var munnew;
	var sumbox;
	var databox;
	function clickboxs(){
		$(".Muli").find("li").on("touchend",function() {		
			if(Fc) {
				Fc = false;
				$(this).siblings().removeClass("sd");
				$(this).addClass("sd");
				var index = $(this).index(); //获取点击文章数
				ArticleNumber = index;
				//你假装这个定时函数是你的post，deta是请求来的数据
				var nums=$(this).find("span").text();
				$(".Huanxing").removeClass("hxsd");
				indexicos=1;
				ajaxs("http://"+domain+"/Home/Novel/ajaxgetchapter?novel_id="+ids+"&chapter_id="+nums);	
				document.getElementById("myFrame").src = "/Home/Novel/tongji.html?tongji="+tongjiurl+"";
			}			
		});
	}
	function getchapterlist(){
		$.ajax({
			url: "http://"+domain+"/Home/Novel/ajaxgetchapterlist?novel_id="+ids,
			type: 'get',
			dataType: 'json',
			async:true,
			success: function(data) {
				databox=data;				
				if(numplus+15>=data.length){
					numplus=data.length-1;
				}else{
					numplus+=15;
				}
				if(munnew-15<=0){
					munnew=0;
				}else{
					munnew-=15;
				}
				for(var i=munnew;i<=numplus;i++){
					var title=data[i].title;
					var chapter=data[i].chapter;
					numids=data[i].chapter_id;
					$(".Muli").find("ul").append("<li>"+chapter+" "+title+"<span style='display: none;'>"+numids+"</span></li>");
				};						
			},
			beforeSend:function(){
				$(".swiper-button-next,.swiper-button-prev").hide();
				$(".jzhd").show();
			},
			complete:function(){
				if(sumbox>15){
					toppd=true;
				}else{
					toppd=false;
				}
				$(".swiper-button-next,.swiper-button-prev").show();
				$(".jzhd").hide();					
				clickboxs();
			}
		});	
	}
	var numbers=15;
	var toppd;
	var numsoder=15;
	function loginfronts(){	
		var munnewss=munnew-1;
		if(munnew==0){
			layer.open({
			    content: '没有啦!'
			    ,skin: 'msg'
			    ,time: 1.2
			});	
		}		
		if(munnew-15<=0){
			numsoder=munnew;
			munnew=0;			
			toppd=false;
		}else{
			munnew-=15;
		}
		for(var i=munnewss;i>=munnew;i--){
			var title=databox[i].title;
			var chapter=databox[i].chapter;
			numids=databox[i].chapter_id;
			$(".Muli").find("ul").prepend("<li>"+chapter+" "+title+"<span style='display: none;'>"+numids+"</span></li>");
		};
		numbers+=15;
		order_set+=numsoder;	
		clickboxs();
	}	
	function loginnext(){
		var munnews=numplus+1;
		if(numplus==databox.length-1){
			layer.open({
			    content: '没有啦!'
			    ,skin: 'msg'
			    ,time: 1.2
			});	
		}
		if(numplus+15>=databox.length){
			numplus=databox.length-1;			
		}else{
			numplus+=15;
		}
		for(var i=munnews;i<=numplus;i++){
			var title=databox[i].title;
			var chapter=databox[i].chapter;
			numids=databox[i].chapter_id;
			$(".Muli").find("ul").append("<li>"+chapter+" "+title+"<span style='display: none;'>"+numids+"</span></li>");
		};	
		clickboxs();
	}
	$('.Muli ul').on("scroll",function(e){		
		if($(this).scrollTop()>=($(this)[0].scrollHeight-$(this).height())){
			$(".lbottom").css("visibility","visible");
			setTimeout(function(){
				$(".lbottom").css("visibility","hidden");
			},300)
			loginnext();
		}
		if($(this).scrollTop()<=0){
			$(".ltop").css("visibility","visible");
			setTimeout(function(){
				$(".ltop").css("visibility","hidden");
			},300)
			if(toppd==true){
				$(".Muli").find("ul").scrollTop($(this).height());//$(this).height()+200
			}else{
				$(".Muli").find("ul").scrollTop(1);
				toppd=false;
			}	
			loginfronts();				
		}
	})
	$(".muluButton").on("touchstart",function(even) {			
		$(".Muli").show();
		$(".Muli").find("ul li").eq(order_set).siblings().removeClass("sd");
		$(".Muli").find("ul li").eq(order_set).addClass("sd");
		if(panduan){
			setTimeout(function(){
				$(".Muli").find("ul").scrollTop(0);
				if($(".Muli").find("ul li").eq(order_set).offset()!=undefined){
					var tops=$(".Muli").find("ul li").eq(order_set).offset().top;
				}				
				$(".Muli").find("ul").scrollTop(tops+1);
			})
			panduan=false;
		}else{
			$(".Muli").find("ul").scrollTop(0);
			var tops=$(".Muli").find("ul li").eq(order_set).offset().top;
			$(".Muli").find("ul").scrollTop(tops+1);
		}
		$(".Muli").find("ul").on("touchstart",function(e){
			if($(this).scrollTop()<=0){
				$(".Muli").find("ul").scrollTop(1);
			}
			Fc=true;
		})
		$(".Muli").find("ul").on("touchmove",function(e){
			Fc=false;
		})		
		$(".Muli").find("#fdleft").on("touchstart",function(even){
			$(".Muli").hide();
		})	
	});
	//夜间模式转换
	var YeBool = true;
	$(".Yejian").on("touchstart",function(even) {
		if(YeBool) {
			$(".swiper-container").addClass("YejianMos");
			$(this).find("img").attr("src", "http://"+domain+"/Public/page/img/icon-ty.png");
			$(this).find("p").text('日间');
			$('.workgybox').addClass('workgyboxyj');
			$('.workgybox').find('.worktitle').addClass('workgyboxyj');
			$('.swiper-pagination-progressbar').addClass('swiper-pagination-progressbaryj');
			YeBool = false;
		} else {
			$(".swiper-container").removeClass("YejianMos");
			$(this).find("img").attr("src", "http://"+domain+"/Public/page/img/icon-yl.png");
			$(this).find("p").text('夜间');
			$('.workgybox').removeClass('workgyboxyj');
			$('.workgybox').find('.worktitle').removeClass('workgyboxyj');
			$('.swiper-pagination-progressbar').removeClass('swiper-pagination-progressbaryj');
			YeBool = true;
		}
	});
	$(".Shuqian").on("touchstart",function(even) {
		$.ajax({
            url: '/Home/Novel/addbooksign?chapter_id='+init_chapter_id+'&novel_id='+ids,
            type: 'GET',
            contentType: 'application/json'
        })
		layer.open({
		    content: '添加书签成功!'
		    ,skin: 'msg'
		    ,time: 1.2
		});			
	});		
	var overscroll = function(el) {
		el.addEventListener('touchstart', function() {
		var top = el.scrollTop
		var totalScroll = el.scrollHeight
		var currentScroll = top + el.offsetHeight;
		    if(top === 0) {
		    	el.scrollTop = 1;
		    } else if(currentScroll === totalScroll) {
		    	el.scrollTop = top - 1;
		    }
		});
		el.addEventListener('touchmove', function(evt) {
		    if(el.offsetHeight < el.scrollHeight)
		    	evt._isScroller = true;
	    });
	}
	overscroll(document.querySelector('.Muli ul'));
	document.body.addEventListener('touchmove', function(evt) {
		if(!evt._isScroller) {
			evt.preventDefault();
		}
	});	
</script>